
const { ccclass, property } = cc._decorator;

@ccclass('RukoPanel')
export class RukoPanel extends cc.Component {

    public closeBtn() {
        this.node.active = false;
    }

    public openSideBar() {
        this.doOpenSideBar(() => {
            this.closeBtn();
        }, () => {
            this.closeBtn();
        });
    }

    private doOpenSideBar(successCallBack: Function, errorCallBack: Function = null) {
        const isTT = (window as any).tt != undefined;
        if (!isTT) return;

        (window as any).tt.navigateToScene({
            scene: "sidebar",
            success: (res) => {
                console.log("navigate to scene success");
                successCallBack && successCallBack()
                // 跳转成功回调逻辑
            },
            fail: (res) => {
                console.log("navigate to scene fail: ", res);
                errorCallBack && errorCallBack()
                // 跳转失败回调逻辑
            },
        });
    }

}